#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cassert>
#include <string>
#include <unistd.h>
#include <cerrno>
#include <fcntl.h>
#include "street.hpp"
using namespace std;
int main()
{
    int fd = open(name.c_str(), O_WRONLY);
    if (fd < 0)
    {
        cerr << errno << ":" << strerror(errno) << endl;
        return 1;
    }
    while (true)
    {
        cout << "Please input your message:" << endl;
        char buf[MAX];
        fgets(buf, sizeof(buf), stdin);
        buf[strlen(buf)-1]='\0';
        int n = write(fd, buf, strlen(buf));
        if (n < 0)
        {
            cerr << errno << ":" << strerror(errno) << endl;
            return 2;
        }
        if(strcasecmp(buf,"quit")==0)
        {
            break;
        }
        
    }
    close(fd);
    return 0;
}